# Maintainer: Filipe Laíns (FFY00) <lains@archlinux.org>
# Maintainer: Maxime Gauduin <alucryd@archlinux.org>

_pkgname=httptools
pkgname=python-$_pkgname
pkgver=0.5.0
pkgrel=2
pkgdesc='Fast HTTP parser'
arch=('loong64' 'x86_64')
url='https://github.com/MagicStack/httptools'
license=('MIT')
depends=('python' 'http-parser')
makedepends=('git' 'python-setuptools' 'python-wheel' 'cython')
_tag=7b1b43b4790558ff39a3dd81b72a3793091bcd49
source=("git+$url#tag=$_tag"
        'git+https://github.com/nodejs/llhttp.git')
b2sums=('SKIP'
        'SKIP')

prepare() {
  cd $_pkgname

  sed -i 's|CYTHON_DEPENDENCY =.*|CYTHON_DEPENDENCY = "Cython"|' setup.py
  sed -i 's|../../vendor/http-parser/http_parser.h|/usr/include/http_parser.h|' $_pkgname/parser/cparser.pxd

  git rm vendor/http-parser

  git config --global protocol.file.allow always

  git submodule init
  git config submodule.vendor/llhttp.url "$srcdir"/llhttp
  git submodule update
}

pkgver() {
  cd $_pkgname
  git describe --tags | sed 's/^v//'
}

build() {
  cd $_pkgname
  python setup.py build build_ext --use-system-http-parser
}

package() {
  cd $_pkgname
  python setup.py install --root="$pkgdir" --optimize=1 --skip-build
  install -Dm 644 LICENSE "$pkgdir"/usr/share/licenses/$pkgname/LICENSE
}

# vim: ts=2 sw=2 et:
